#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include<QPoint>
#include<QJsonArray>
#include<QMouseEvent>
#include<QJsonObject>
#include<QListWidget>
#include<QListWidgetItem>
#include<QFileDialog>
#include"volumetool.h"
#include "musiclist.h"
#include"commonpage.h"
#include<QMediaPlaylist>
#include <QPropertyAnimation>
#include <QSqlDatabase>
#include "lrcpage.h"
QT_BEGIN_NAMESPACE
namespace Ui {
class Widget;
}
QT_END_NAMESPACE

class Widget : public QWidget
{
    Q_OBJECT

public:
    MusicList musicList;
    QSqlDatabase sqlite;
    Widget(QWidget *parent = nullptr);
    ~Widget();
    QPoint dragPosition;
    //播放器相关
    QMediaPlayer* player;
    // 要多⾸歌曲播放，以及更复杂的播放设置，需要给播放器设置媒体列表
    QMediaPlaylist* playList;       //当前歌曲的播放列表(在不同页面其播放列表都不同，并且每次切换界面都要更新此播放列表)
    int curPlayMusicIndex;
    CommonPage* currentPage;
    LrcPage* lrcPage;
    bool isDrag; // 为true时候窗⼝才能拖拽
    VolumeTool* vt=new VolumeTool(this);
    void InitUi();
    void initSQLite();
    void connectSignalAndSlot();
    void onBtFormClick(int id);
    void mouseMoveEvent(QMouseEvent*ev)override;
    void mousePressEvent(QMouseEvent*ev)override;
    void RenewLikeFromMusicId(bool like,QString MusicId);
    void onPlayStateChanged();
    void onPlaybackModeChanged(QMediaPlaylist::PlaybackMode playbackMode);
    void onPlayAll(PageType pageType);
    void playAllOfCommonPage(CommonPage *commonPage, int index);
    void onCurrentIndexChanged(int index);
    void playMusicByIndex(CommonPage* page, int index);
    void setPlayerVolume(int vomume); // 设置⾳量⼤⼩
    void initPlayer();
    void initMusicList();
    void onMusicSliderChanged(float value); // 进度条改变
    void onMetaDataAvailableChangedChanged(bool available);
    void onPositionChanged(qint64 duration);
    QJsonArray randomPiction();
     QJsonArray RandomPicture();
     // 歌曲持续时⻓改变时[歌曲切换]
     void onDurationChanged(qint64 duration);
   void setMusicSilence(bool isMuted);
   QString getLrcFilePath() const;
signals:
private slots:
    void on_quit_clicked();

    void on_volume_clicked();

    void on_addLocal_clicked();

    void on_play_clicked();

    void on_playPrev_clicked();

    void on_playNext_clicked();

    void on_playMode_clicked();

    void on_pushButton_3_clicked();

    void on_lrcWord_clicked();

private:
    Ui::Widget *ui;
};
#endif // WIDGET_H
